<?php


// 本类由系统自动生成，仅供测试用途
class CommonUtil extends Action {
	/**
	 * 判断是否搜索引擎的爬虫 true等于是 false表示不是爬虫
	 */
	function isCrawler() {
		$agent = strtolower($_SERVER['HTTP_USER_AGENT']);
		if (!empty ($agent)) {
			$spiderSite = array (
				"TencentTraveler",
				"Baiduspider+",
				"BaiduGame",
				"Googlebot",
				"msnbot",
				"Sosospider+",
				"Sogou web spider",
				"ia_archiver",
				"Yahoo! Slurp",
				"YoudaoBot",
				"Yahoo Slurp",
				"MSNBot",
				"Java (Often spam bot)",
				"BaiDuSpider",
				"Voila",
				"Yandex bot",
				"BSpider",
				"twiceler",
				"Sogou Spider",
				"Speedy Spider",
				"Google AdSense",
				"Heritrix",
				"Python-urllib",
				"Alexa (IA Archiver)",
				"Ask",
				"Exabot",
				"Custo",
				"OutfoxBot/YodaoBot",
				"yacy",
				"SurveyBot",
				"legs",
				"lwp-trivial",
				"Nutch",
				"StackRambler",
				"The web archive (IA Archiver)",
				"Perl tool",
				"MJ12bot",
				"Netcraft",
				"MSIECrawler",
				"WGet tools",
				"larbin",
				"Fish search",
				"Bingbot",
				"360Spider",

				
			);
			foreach ($spiderSite as $val) {
				$str = strtolower($val);
				if (strpos($agent, $str) !== false) {
					return true;
				}
			}
			return false;
		} else {
			return false;
		}
	}

	function checkBrower() {
		$agent = $_SERVER['HTTP_USER_AGENT']; 
 		if(strpos($agent,"MSIE")){
 			$this->assign("Browser",'IE');
 		}else{
 			$this->assign("Browser",'Chrome');
 		}
// 
//		else if(strpos($agent,"MSIE 8.0"))    
//		  echo "Internet Explorer 8.0"; 
//		 
//		else if(strpos($agent,"MSIE 7.0")) 
//		  echo "Internet Explorer 7.0"; 
//		 
//		else if(strpos($agent,"MSIE 6.0")) 
//		  echo "Internet Explorer 6.0"; 
//		 
//		else if(strpos($agent,"Firefox/3")) 
//		  echo "Firefox 3"; 
//		 
//		else if(strpos($agent,"Firefox/2")) 
//		  echo "Firefox 2"; 
//		 
//		else if(strpos($agent,"Chrome")) 
//		  echo "Google Chrome"; 
//		 
//		else if(strpos($agent,"Safari")) 
//		  echo "Safari"; 
//		 
//		else if(strpos($agent,"Opera")) 
//		  echo "Opera"; 
//		 
//		else    
//		  echo $agent; 
		
	}
	
	function checkBrowerReturn() {
		$agent = $_SERVER['HTTP_USER_AGENT']; 
 		if(strpos($agent,"MSIE")){
 			return 'IE';
 		}else{
 			return 'NoIE';
 		}		
	}
	
	/**
	 * 判断数字和英文
	 */
	function checkWord($str){
		$mb = mb_strlen($str,'utf-8');
		$st = strlen($str);
		if($st==$mb){
			return 1;
		}
		if($st%$mb==0 && $st%3==0){
			return 2;
		}
		return 3;
	}

}